﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace SnongPhoneShop.Models
{
    public class Cart
    {
        [Required]
        public string MaSanPham { get; set; }

        [Required]
        [Range(1, 5)]
        public int SoLuong { get; set; }

        public SanPham SanPham { 
            get 
            {
                SnongPhoneShopEntities db = new SnongPhoneShopEntities();
                return db.SanPhams.First(m => m.MaSanPham.Equals(MaSanPham));
            } 
        }
    }
}